package org.messycode.util;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SetUtil
{
    public static <E> E first(List<E> items)
    {
        return items.get(0);
    }

    public static <E> E first(Set<E> items)
    {
        throw new UnsupportedOperationException("Don't look for the first item in a set, it's rarely deterministic!");
    }

    public static <E> Set<E> setOf(E... values)
    {
        Set<E> items = new HashSet<E>();

        for (E element : items)
        {
            items.add(element);
        }

        return items;
    }
}
